function [trend] = gTrend(dates, data, alpha, toPlot)
%GTREND Test the given data for the presence of a trend and plot the trend
% if it exists

% INPUTS
%   dates:  a vector of Matlab datenums
%   data:   a vector of data
%   alpha:  alpha value used in significance test (default .05)
%   toPlot: boolean value (1 = plot)
%
% OUTPUTS
%   trend:  boolean value (1 = significant trend)
    
    if(nargin<4)
            toPlot = 0;
    end
    if(nargin<3)
            alpha = .05;
    end
    [taub tau h sig Z S sigma sen n senplot CIlower CIupper D Dall C3] = ktaub([dates/365.25 data], alpha, toPlot);
    trend = h;
    if(toPlot)
        title(['Trend with ',num2str(alpha),' confidence interval'])
        xlabel('Time (years)')
        ylabel('Dependent variable')
    end

end

